package com.blank.gpstest;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: blank
 * @date : 2022/7/22
 * @desc :
 * @url : https://gitee.com/hyx_blank
 */
public class MyAdapter extends BaseAdapter {
    private List<String> strings;
    private LayoutInflater mInflater = null;

    public MyAdapter(Context context) {
        this.mInflater = LayoutInflater.from(context);
        strings = new ArrayList<>();
    }

    @Override
    public int getCount() {
        return strings.size();
    }

    @Override
    public Object getItem(int i) {
        return strings.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_list, null);
        }
        TextView title = convertView.findViewById(R.id.id_treenode_name);
        title.setText(i + "***" + strings.get(i));
        return convertView;
    }


    public void setData(List<String> list) {
        strings = list;
        notifyDataSetChanged();
    }
}
